<?php

namespace App\Admin\Controllers;

use Encore\Admin\Grid;
use App\Models\GoldEnd;
use Encore\Admin\Controllers\AdminController;

class GoldEndsController extends AdminController
{
    protected $title = '商品终结';

    protected function grid()
    {
        $grid = new Grid(new GoldEnd());
        $grid->model()->orderByDesc('id');

        $grid->column('id', 'ID');
        $grid->column('gold_round_id', '场次');
        $grid->column('gold_product_id', '商品');
        $grid->column('ended_at', '终结')->display(function ($value) {
            return $value ? (string)$this->ended_at : '';
        });
        $grid->column('created_at', '创建')->display(function () {
            return (string)$this->created_at;
        });

        $grid->disableRowSelector();
        $grid->disableCreateButton();
        $grid->disableExport();
        $grid->disableActions();

        return $grid;
    }
}
